package com.txby;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@WebFilter(urlPatterns = "/*", filterName = "xssAndSqlFilter")
public class XssAndSqlFilter implements Filter {
	FilterConfig filterConfig = null;
	private static Logger logger = LoggerFactory
			.getLogger(XssAndSqlFilter.class);

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain filterChain) throws IOException, ServletException {
		HttpSession session = ((HttpServletRequest) request).getSession();
		// 获得用户请求的URI
//		String path = ((HttpServletRequest) request).getRequestURI();
		String path=((HttpServletRequest) request).getServletPath();
		path=path.substring(path.lastIndexOf("/")+1, path.length());
		// 项目路径
		String contextPath = ((HttpServletRequest) request).getContextPath();
		// 请求路径
		String contextPath2 = ((HttpServletRequest) request).getServletPath();
	   XssAndSqlHttpServletRequestWrapper xssRequest = new XssAndSqlHttpServletRequestWrapper(
				(HttpServletRequest) request);
		filterChain.doFilter(xssRequest, response);

	}

	public void destroy() {
		this.filterConfig = null;

	}
	public void init(FilterConfig filterConfig) throws ServletException {
		this.filterConfig = filterConfig;

	}

}
